home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / stdint.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-21  |  4.3 KB  |  200 lines

  1. /* Copyright (C) 2001 by Digital Mars */
  2. /* www.digitalmars.com */
  3.  
  4. #if __DMC__ || __RCC__
  5. #pragma once
  6. #endif
  7.  
  8. #ifndef __STDINT_H
  9. #define __STDINT_H 1
  10.  
  11. #define __LONGLONG (__INTSIZE == 4)
  12.  
  13. /* Exact sizes */
  14. typedef signed char int8_t;
  15. typedef unsigned char uint8_t;
  16.  
  17. typedef short int16_t;
  18. typedef unsigned short uint16_t;
  19.  
  20. typedef long int32_t;
  21. typedef unsigned long uint32_t;
  22.  
  23. /* At least sizes */
  24.  
  25. typedef signed char int_least8_t;
  26. typedef unsigned char uint_least8_t;
  27.  
  28. typedef short int_least16_t;
  29. typedef unsigned short uint_least16_t;
  30.  
  31. typedef long int_least32_t;
  32. typedef unsigned long uint_least32_t;
  33.  
  34. /* Fastest minimum width sizes */
  35.  
  36. typedef signed char int_fast8_t;
  37. typedef unsigned char uint_fast8_t;
  38.  
  39. typedef int int_fast16_t;
  40. typedef unsigned uint_fast16_t;
  41.  
  42. typedef long int_fast32_t;
  43. typedef unsigned long uint_fast32_t;
  44.  
  45. /* Integer pointer holders */
  46.  
  47. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__VCM__)
  48. typedef long intptr_t;
  49. typedef unsigned long uintptr_t;
  50. #else
  51. typedef int intptr_t;
  52. typedef unsigned uintptr_t;
  53. #endif
  54.  
  55. /* Greatest width integer types */
  56.  
  57. #if __LONGLONG
  58. typedef long long intmax_t;
  59. typedef unsigned long long uintmax_t;
  60. #else
  61. typedef long intmax_t;
  62. typedef unsigned long uintmax_t;
  63. #endif
  64.  
  65. /* long long typedefs */
  66.  
  67. #if __LONGLONG
  68.  
  69. typedef long long int64_t;
  70. typedef unsigned long long uint64_t;
  71.  
  72. typedef long long int_least64_t;
  73. typedef unsigned long long uint_least64_t;
  74.  
  75. typedef long long int_fast64_t;
  76. typedef unsigned long long uint_fast64_t;
  77.  
  78. #endif
  79.  
  80. #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
  81.  
  82. #define INT8_MIN    (-128)
  83. #define INT8_MAX    127
  84. #define UINT8_MAX    0xFF
  85.  
  86. #define INT16_MIN    (-32768)
  87. #define INT16_MAX    32767
  88. #define UINT16_MAX    0xFFFF
  89.  
  90. #define INT32_MIN    (-2147483647L - 1)
  91. #define INT32_MAX    2147483647
  92. #define UINT32_MAX    0xFFFFFFFF
  93.  
  94. #define INT_LEAST8_MIN    INT8_MIN
  95. #define INT_LEAST8_MAX    INT8_MAX
  96. #define UINT_LEAST8_MAX    UINT8_MAX
  97.  
  98. #define INT_LEAST16_MIN    INT16_MIN
  99. #define INT_LEAST16_MAX    INT16_MAX
  100. #define UINT_LEAST16_MAX UINT16_MAX
  101.  
  102. #define INT_LEAST32_MIN    INT32_MIN
  103. #define INT_LEAST32_MAX    INT32_MAX
  104. #define UINT_LEAST32_MAX UINT32_MAX
  105.  
  106. #define INT_FAST8_MIN    INT8_MIN
  107. #define INT_FAST8_MAX    INT8_MAX
  108. #define UINT_FAST8_MAX    UINT8_MAX
  109.  
  110. #if __INTSIZE == 4
  111. #define INT_FAST16_MIN    INT32_MIN
  112. #define INT_FAST16_MAX    INT32_MAX
  113. #define UINT_FAST16_MAX    UINT32_MAX
  114. #else
  115. #define INT_FAST16_MIN    INT16_MIN
  116. #define INT_FAST16_MAX    INT16_MAX
  117. #define UINT_FAST16_MAX    UINT16_MAX
  118. #endif
  119.  
  120. #define INT_FAST32_MIN    INT32_MIN
  121. #define INT_FAST32_MAX    INT32_MAX
  122. #define UINT_FAST32_MAX    UINT32_MAX
  123.  
  124. #if __LONGLONG
  125.  
  126. #define INT64_MIN    (-9223372036854775807LL-1LL)
  127. #define INT64_MAX    9223372036854775807LL
  128. #define UINT64_MAX    0xFFFFFFFFFFFFFFFF
  129.  
  130. #define INT_LEAST64_MIN    INT64_MIN
  131. #define INT_LEAST64_MAX    INT64_MAX
  132. #define UINT_LEAST64_MAX UINT64_MAX
  133.  
  134. #define INT_FAST64_MIN    INT64_MIN
  135. #define INT_FAST64_MAX    INT64_MAX
  136. #define UINT_FAST64_MAX    UINT64_MAX
  137.  
  138. #endif
  139.  
  140. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__VCM__) || __INTSIZE == 4
  141. #define INTPTR_MIN    INT32_MIN
  142. #define INTPTR_MAX    INT32_MAX
  143. #define UINTPTR_MAX    UINT32_MAX
  144. #else
  145. #define INTPTR_MIN    INT16_MIN
  146. #define INTPTR_MAX    INT16_MAX
  147. #define UINTPTR_MAX    UINT16_MAX
  148. #endif
  149.  
  150. #if __LONGLONG
  151. #define INTMAX_MIN    INT64_MIN
  152. #define INTMAX_MAX    INT64_MAX
  153. #define UINTMAX_MAX    UINT64_MAX
  154. #define INTMAX_C(v)    v##LL
  155. #define UINTMAX_C(v)    v##ULL
  156. #else
  157. #define INTMAX_MIN    INT32_MIN
  158. #define INTMAX_MAX    INT32_MAX
  159. #define UINTMAX_MAX    UINT32_MAX
  160. #define INTMAX_C(v)    v##L
  161. #define UINTMAX_C(v)    v##UL
  162. #endif
  163.  
  164. #if __INTSIZE == 4
  165. #define PTRDIFF_MIN    INT32_MIN
  166. #define PTRDIFF_MAX    INT32_MAX
  167. #define SIG_ATOMIC_MIN    INT32_MIN
  168. #define SIG_ATOMIC_MAX    INT32_MAX
  169. #define SIZE_MAX    UINT32_MAX
  170. #else
  171. #define PTRDIFF_MIN    INT16_MIN
  172. #define PTRDIFF_MAX    INT16_MAX
  173. #define SIG_ATOMIC_MIN    INT16_MIN
  174. #define SIG_ATOMIC_MAX    INT16_MAX
  175. #define SIZE_MAX    UINT16_MAX
  176. #endif
  177.  
  178.  
  179. #define WCHAR_MIN    0
  180. #define WCHAR_MAX    UINT16_MAX
  181.  
  182. #define WINT_MIN    0
  183. #define WINT_MAX    UINT16_MAX
  184.  
  185. #define INT8_C(v)    v
  186. #define UINT8_C(v)    v
  187. #define INT16_C(v)    v
  188. #define UINT16_C(v)    v
  189. #define INT32_C(v)    v##L
  190. #define UINT32_C(v)    v##UL
  191.  
  192. #if __LONGLONG
  193. #define INT64_C(v)    v##LL
  194. #define UINT64_C(v)    v##ULL
  195. #endif
  196.  
  197. #endif
  198.  
  199. #endif
  200.